package com.adamfass.tractorbeam;

import com.jme.bounding.BoundingSphere;
import com.jme.intersection.CollisionResults;
import com.jme.math.Vector3f;
import com.jme.scene.Node;
import com.jme.scene.shape.Sphere;
import com.jmex.physics.PhysicsSpace;

public class Ball extends PhysicsGameObject {
  private static final float MASS = 8;
  public static final float RADIUS = 10;
  
  public Ball(Node rootNode, PhysicsSpace physicsSpace, 
              Vector3f worldTranslation, Vector3f velocity) {
      super(physicsSpace);
      physicsNode.createSphere("ball physics sphere");
      physicsNode.setLocalTranslation(worldTranslation);
      physicsNode.setLocalScale(RADIUS);
      physicsNode.setMass(MASS);
      physicsNode.setLinearVelocity(velocity);
      physicsNode.updateGeometricState(0, true);
      rootNode.attachChild(physicsNode);
      
      physicsNode.attachChild(new Sphere("ball geometry", 10, 10, 1));
      physicsNode.setModelBound(new BoundingSphere());
      physicsNode.updateModelBound();
  }
  
  public void calculateCollisions(Node scene, CollisionResults results) {
    physicsNode.calculateCollisions(scene, results);
  }
}
